﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace newTurtle8
{
    partial class SoldierCard : UserControl
    {
        public enum PanelState { Default, OpenSoldierDataCard, NewSoldierDataCard};

        PictureBox picBoxMain = new System.Windows.Forms.PictureBox();
        Company company = Company.getInstance();

        public SoldierCard()
        {
            InitializeComponent();

            buttonSoldierDataForm.Tag = new SoldierDataForm();
            buttonSearchCard.Tag = new SearchCard(this);
            buttonQualifiedView.Tag = new FitnessTrackView();
            buttonMainPage.Tag = picBoxMain;

            //setting pucBoxMain preferences
            picBoxMain.SizeMode = PictureBoxSizeMode.StretchImage;
            String currentDir = System.IO.Directory.GetCurrentDirectory();
            picBoxMain.Image = Image.FromFile(currentDir + @"\images\Soldier.jpg");
            picBoxMain.Dock = DockStyle.Fill;
            picBoxMain.BorderStyle = BorderStyle.FixedSingle;


            changeMainPanelToDefault();
            this.Dock = DockStyle.Fill;
        }

       
        public void openSoldierCard(string armyID)
        {
            buttonSoldierDataForm.Tag = new SoldierDataForm(armyID);
            changeMainPanel(buttonSoldierDataForm, EventArgs.Empty);
        }

        private void changeMainPanel(object sender, EventArgs e)
        {
            Control ctrl = (Control)(((Control)sender).Tag);
            if (!panelMain.Controls.Contains(ctrl))
            {
                panelMain.Controls.Clear();
                panelMain.Controls.Add(ctrl);
            }
        }

        public void changeMainPanelToDefault()
        {
            panelMain.Controls.Clear();
            panelMain.Controls.Add(picBoxMain);
        }

        public void createNewSoldierDataForm()
        {
            buttonSoldierDataForm.Tag = new SoldierDataForm();
            changeMainPanel(buttonSoldierDataForm, EventArgs.Empty);
        }
    }
}
